What’s an Invoice?
An invoice is a document sent by a seller to a buyer, outlining the goods or services provided and the total cost for those goods or services. It typically includes the date of the transaction, the invoice number, the customer’s contact information, and a description of the goods or services provided. In addition, it may also include the quantity of each item purchased, the unit price, and the total amount due.
The invoice serves as a record of the transaction and is often used for accounting and tax purposes. It also serves as a means of payment request to the customer. Invoices are commonly used in business-to-business transactions, but can also be used in consumer transactions.
There are a lot of tools allowing you to create invoices, ranging from Accounting Software, to good old Word Processors. The manual effort needed to create invoices also varies on this scale. With dedicated invoicing software it is generally easier because the offer ready to use templates and have some sort of built-in editor allowing users to fill in the different invoice fields. On the other side of this spectrum are document editors like Microsoft Word and spreadsheet editors like Microsoft Excel that allow the manual creation of invoices, but offer less out-of-the-box automation.
Somewhere in the middle are document generators such as DocuGenerate, that can add automation on top of existing templates. Some use WISIWIG web editors to create and edit the templates, but for DocuGenerate we decided to use regular Word documents as templates because they are widely used, so you don’t need to learn a new software and also because of the flexibility and customization options that regular Word documents offer. This way, you can easily transform an existing invoice into a reusable template, saving time and effort on future invoicing tasks.
Creating the Invoice Template
For the purpose of this tutorial, we’ll use a simple Sales Invoice containing just some basic information and a table with dummy items. You’ll learn how to transform this invoice into a template, so it can be used to generate similar invoices for other clients, that will have the same layout but different content.
A merge tag is a special placeholder within a document template that can be automatically replaced with data from a database or spreadsheet. The idea is to generate personalized documents in bulk, rather than having to manually create each one.
For example, a template for an invoice might include merge tags for invoice number, the client’s name, address, and other relevant information, which would be automatically filled in for each client based on data stored in a spreadsheet. This saves time and reduces errors compared to manual data entry, and is commonly used in industries such as real estate, finance, and insurance.
The first step for adding merge tags is to identify the areas of the invoice that need to be dynamic, and for each area select the existing text and replace it with a corresponding merge tag. For example, we’ll replace the text #0135
with [Invoice No]
, then March 1st, 2023
with [Invoice Date]
and so on, as you can see in the following video:
After doing the first step, the invoice template should contain the merge tags [Invoice No]
, [Invoice Date]
[CUSTOMER NAME]
, [STREET]
, [CITY]
, [ST]
, [ZIP CODE]
, like in the image below. As you can see, there is no particular rule for formatting the merge tags, you can use all caps, capitalized words, as long as they use the same tag delimiters, which in this case are [
for the left delimiter and ]
for the right delimiter.
You are free to use any delimiters you want when creating the template, like for example {Invoice No}
, [[Invoice No]]
, or even more exotic delimiters like ![[[Invoice No]]]!
. The DocuGenerate parser can automatically detect the most commonly used tags when uploading a template, but if you use some uncommon delimiters that are not detected, you can always update them in the template settings so that the merge tags can be recognized successfully.
Make the Items Table Dynamic
The next step in creating the invoice template is to transform the static items table into a dynamic one. Invoice items are the specific products or services being billed to a customer. They appear in the invoice in a table or list format and typically include the item name, description, quantity, unit price, and total amount. The invoice items make up the total amount due for the invoice and provide a detailed breakdown of what the customer is paying for.
Like for the first step, we’re going to replace the existing text with corresponding merge tags. For example, Item 1
is replaced with [Name]
, 500
is replaced with [Quantity]
, $175
is replaced with [Price]
and $87,500
is replaced with [Amount]
. We only need to edit the first line of the table and delete the content of the other lines, because they will be generated dynamically from the items list.
We’re going to use a special syntax to iterate over the items list and add multiple rows to the table, where [#Items]
marks the beginning of the table loop and [/]
marks the end of the table loop. In the end, the table should look like this:
ITEM | QTY | PRICE | TOTAL |
[#Items][Name] | [Quantity] | [Price] | [Amount][/] |
And here’s a short video of the whole transformation process of the table containing the items:
Testing the Template
After making all these previous changes, the invoice template should look like this. You can download a copy of the modified invoice if you don’t want to go through all these steps but rather have the final version of the invoice template for testing.
First you’ll need to create a new template by uploading the invoice template file. Then go to Generate a new document and select the JSON data format. You can paste the following JSON value in the input text area, or if you prefer you can download a JSON file containing this data.
[
{
"Invoice No": "58-519-8945",
"Invoice Date": "03-01-2023",
"CUSTOMER NAME": "Wisozk Inc",
"STREET": "1569 Fair Oaks Way",
"CITY": "Philadelphia",
"ST": "Pennsylvania",
"ZIP CODE": "19184",
"Total": "$180",
"Items": [
{
"Name": "Table",
"Quantity": 1,
"Price": "$80",
"Amount": "$80"
},
{
"Name": "Chairs",
"Quantity": 4,
"Price": "$25",
"Amount": "$100"
}
]
}
]
It should look something like this in the DocuGenerate web app:
The if you go ahead and generate the PDF document with the default merge options, the result should be like the one below. If you don’t want to try it right now, you can just download a copy of the generated PDF invoice to see what it looks like.
Conclusion
An invoice is an essential document that outlines the goods or services provided to a buyer, the cost, and other details of a transaction. Invoices serve as a record of the transaction and are used for accounting and tax purposes. There are various tools available to create invoices, including accounting software, word processors, and document generators. In this article, we have demonstrated how to transform a sales invoice into a reusable template by adding merge tags using a document generator.
Resources